package com.shuihu.springcloud.service.impl;

import com.shuihu.springcloud.domain.TbSysUser;
import com.shuihu.springcloud.mapper.TbSysUserMapper;
import com.shuihu.springcloud.service.AdminService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;


import javax.annotation.Resource;
import java.util.List;

/**
 * @author shuihu
 * @create 2020-05-31 15:20
 */
@Service
@Transactional(readOnly = true)
public class AdminServiceImpl implements AdminService {

    @Resource
    private TbSysUserMapper tbSysUserMapper;

    @Transactional(readOnly = false)
    @Override
    public void register(TbSysUser tbSysUser) {
        tbSysUserMapper.insert(tbSysUser);
    }

    @Override
    public TbSysUser login(String loginCode, String plantPassword) {
//        Example example = new Example(TbSysUser.class);
//        example.createCriteria().andEqualTo("loginCode", loginCode);


        List<TbSysUser> tbSysUser = tbSysUserMapper.selectAll();
        if (tbSysUser != null) {
            String password = DigestUtils.md5DigestAsHex(plantPassword.getBytes());

        }

        return null;
    }
}
